<?php
session_start();
include_once("../service/userService.php");
include_once("../util/constant.php");

//$fullName, $gender, $email, $dob, $address, $username, $password, $status, $phoneNumber
$fullName = $_POST["fullName"];
$gender = $_POST["gender"];
$email = $_POST["emailRegister"];
$dob = $_POST["dob"];
$address = $_POST["address"];
$username = $_POST["username"];
$password = md5($_POST["passwordRegister"]);
$phoneNumber = $_POST["phoneNumber"];
$userId = createUser($fullName, $gender, $email, $dob, $address, $username, $password, $phoneNumber);

if($userId > 0){
	$_SESSION['username'][0] = $userId;
	$_SESSION['username'][1] = $username;
	$_SESSION['username'][2] = 0; // user type
	$_SESSION['userid'] = $userId;	
	echo "<script>window.location.href = '../index.php?a=".INSERT_SUCCESSFULLY."';</script>";
}
else
	echo "<script>window.location.href = '../register.php?a=".INSERT_FAILED."';</script>";

?>